import {
	http
} from '@/node_modules/uview-plus'


// custom  公共接口判断是否带/member

/**
 * @function 获取验证码
 * @param tel 电话号码
 * @param scene 用户端
 */
export const postSendCode = (data, custom = {}) => http.post('/message/sms/sendCode', data, {
	custom: {
		auth: 'base'
	}
});

// 操表员端

/** 
 * @function  获取公共设置
 * @param code 唯一值
 */
export const postMultiGet = (data) => http.post('/setting/multiGet', data, {
	custom: {
		auth: 'base'
	}
});

/**
 * @function  抄表员密码登录
 * @param tel 电话号码
 * @param sms_code 短信验证码
 * @param login_secret 密码
 */
export const meterReaderLogin = (data, custom = {}) => http.post('/auth/meterReader/login/pwd', data, {
	custom: {
		auth: 'base'
	}
});


/**
 * @function 历史抄表
 */
export const waterMeterBill = (data) => http.post('/waterMeterBill/pageList', data, {
	custom: {
		auth: 'server'
	}
});

/**
 * @function 退出登录
 */
export const meterReaderOut = (data) => http.post('/auth/meterReader/login/out', data, {
	custom: {
		auth: 'server'
	}
});


/** 
 * @function  
 * @param code 唯一标识
 */
export const waterMeterBillAdd = (data, custom = {}) => http.post('/waterMeterBill/add', data, {
	custom: {
		auth: 'server'
	}
});


/** 
 * @function  获取openid
 */
export const code2session = (data, custom = {}) => http.post('/wechat/mini/code2session', data, {
	custom: {
		auth: true
	}
});

/** 
 * @function  修改登录密码
 * @param login_secret 设置新的登录密码
 * @param login_secret_confirmation 确认密码
 */
export const updateLoginSecret = (data) => http.post('/user/updateLoginSecret', data);

/** 
 * @function  密码登录
 * @param tel 手机号
 * @param login_secret  密码
 */
export const postLogin = (data) => http.post('/auth/user/login/telAndLoginSecret', data, {
	custom: {
		auth: 'base'
	}
});

/** 
 * @function  验证码登录
 * @param tel 手机号
 * @param sms_code  验证码
 */
export const postLoginSms = (data) => http.post('/auth/user/login/sms', data, {
	custom: {
		auth: 'base'
	}
});

/**
 * @function 刷新usertoken
 * @param refresh_token 长token
 */
export const refreshUserToken = (data, custom = {}) => http.post('/auth/user/login/refreshToken', data, {
	custom: {
		auth: 'user',
		_isRefreshToken: true,
		toast: false,
	}
});

/**
 * @function 刷新token
 * @param refresh_token 长token
 */
export const refreshMeterToken = (data, custom = {}) => http.post('/auth/meterReader/login/refreshToken', data, {
	custom: {
		auth: 'server',
		_isRefreshToken: true,
		toast: false,
	}
});


/** 
 * @function  抄表员端,退出登录
 */
export const loginOut = (data, custom = {}) => http.post('/auth/meterReader/login/out', data, {
	custom: {
		auth: 'base'
	}
});

/**
 * @function 数据上报
 * @param event 事件名
 * @param happen_at 当前unix秒数
 * @param uid uid 
 * @param worker_id 工人id
 * @param ref_query 可选，来源数据，比如扫码的二维码内容
 */
export const dataReport = (data, custom = {}) => http.post('/report/dataReport/add', data, {
	custom: {
		auth: 'base',
		toast: false,
	}
});

/** 
 * @function  获取用户信息
 */
export const getuserInfo = (data, custom = {}) => http.post('/info', data, {
	custom: {
		auth: 'server'
	}
});

/**
 * @function 月度账单详情
 */
export const waterMeterInfo = (data) => http.post('/waterMeter/waterMeterBill/detail', data, {
	custom: {
		auth: 'base'
	}
});

